package com.example.memento;

import java.util.Scanner;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main(String[] args) {
        InputText inputText = new InputText();
        SnapshotHolder snapshotsHolder = new SnapshotHolder();
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
          String input = scanner.next();
          if (input.equals(":list")) {
            System.out.println(inputText.getText());
          } else if (input.equals(":undo")) {
            InputText snapshot = snapshotsHolder.popSnapshot();
            inputText.setText(snapshot.getText());
          } else {
            snapshotsHolder.pushSnapshot(inputText);
            inputText.append(input);
          }
        }
      }
}
